<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>A</title>
</head>
<body>

<iframe src="http://localhost:4000/b.html" frameborder="0" id="frame" onload="load()"></iframe>
<script>
  function load() {
    let frame = document.getElementById('frame')
    frame.contentWindow.postMessage('b页面，你收到消息了没', 'http://localhost:4000') //发送数据
    window.onmessage = function(e) { //监听接受返回数据
      console.log(e.data) //
    }
  }
</script>

</body>
</html>
